﻿using System;
using System.Configuration;

namespace BSDS.Commands.Configuration
{
    public class MailingConfigurationSection : ConfigurationSection
    {
        [ConfigurationProperty("notificationsEnabled", IsRequired = true)]
        public bool NotificationsEnabled
        {
            get { return (bool)this["notificationsEnabled"]; }
        }

        [ConfigurationProperty("successSubjectTemplate", IsRequired = true)]
        public string SuccessSubjectTemplate
        {
            get { return (string) this["successSubjectTemplate"]; }
        }

        [ConfigurationProperty("warningSubjectTemplate", IsRequired = true)]
        public string WarningSubjectTemplate
        {
            get { return (string)this["warningSubjectTemplate"]; }
        }

        [ConfigurationProperty("errorSubjectTemplate", IsRequired = true)]
        public string ErrorSubjectTemplate
        {
            get { return (string)this["errorSubjectTemplate"]; }
        }

        [ConfigurationProperty("smtpServer", IsRequired = true)]
        public string SmtpServer
        {
            get { return (string)this["smtpServer"]; }
        }

        [ConfigurationProperty("smtpPort", IsRequired = true)]
        public int SmtpPort
        {
            get { return (int)this["smtpPort"]; }
        }

        [ConfigurationProperty("enableSsl", IsRequired = false, DefaultValue=true)]
        public bool EnableSsl
        {
            get { return (bool)this["enableSsl"]; }
        }

        [ConfigurationProperty("smtpTimeout", IsRequired = true)]
        public TimeSpan SmtpTimeout
        {
            get { return (TimeSpan) this["smtpTimeout"]; }
        }

        [ConfigurationProperty("senderAccount", IsRequired = true)]
        public string SenderAccount
        {
            get { return (string)this["senderAccount"]; }
        }

        [ConfigurationProperty("senderPassword", IsRequired = true)]
        public string SenderPassword
        {
            get { return (string)this["senderPassword"]; }
        }

        [ConfigurationProperty("recipients", IsRequired = true)]
        public MailingConfigurationReciptientsCollection Recipients
        {
            get { return (MailingConfigurationReciptientsCollection) this["recipients"]; }
        }
    }
}